from sqlalchemy import Column,String,Integer,VARCHAR,Float,DateTime
from application.db_util import db
db.create_all()

#管理员表
class Admin(db.Model):
    __tablename__ = 'admin'
    __table_args__ = {'useexisting': True}
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(255))
    password = db.Column(db.String(255))

#用户表
class User(db.Model):
    __tablename__='user'
    __table_args__={'useexisting':True}
    id=db.Column(db.Integer,primary_key=True)
    username = db.Column(db.String(255))
    password = db.Column(db.String(255))
    nickname = db.Column(db.String(255))
    sex = db.Column(db.String(10))
    email = db.Column(db.String(255))
    phone = db.Column(db.String(255))
    permission = db.Integer

#待办表
class Schedule(db.Model):
    __tablename__='schedule'
    __table_args__={'useexisting':True}
    id=db.Column(db.Integer,primary_key=True)
    title = db.Column(db.String(255))
    value = db.Column(db.String(1000))
    repeat = db.Column(db.Integer)
    alerm = db.Column(db.DateTime)
    repeat_cycle = db.Column(db.DateTime)
    user_id = db.Column(db.Integer)
    finished = db.Column(db.Integer)
    end_time = db.Column(db.DateTime)
    start_time = db.Column(db.DateTime)

#日程表
class Events(db.Model):
    __tablename__ = 'events'
    __table_args__ = {'useexisting': True}
    id = db.Column(db.Integer, primary_key=True)
    start_date = db.Column(db.DateTime)
    end_date = db.Column(db.DateTime)
    text = db.Column(db.String(255))
    user_id = db.Column(db.Integer)
    level = db.Column(db.Integer)


#小组代办
class GroupTask(db.Model):
    __tablename__ = 'group_task'
    __table_args__ = {'useexisting': True}
    id = db.Column(db.Integer, primary_key=True)
    group_id = db.Column(db.Integer)
    task = db.Column(db.String(255))
    finished = db.Column(db.Integer)

    # def __init__(self, id, title,value,repeat,alerm,repeat_cycle,user_id):
    #     self.id = id
    #     self.title = title
    #     self.value = value
    #     self.repeat = repeat
    #     self.alerm = alerm
    #     self.repeat_cycle = repeat_cycle
    #     self.user_id = user_id
    #
    # def __repr__(self):
    #     return '<Schedule(%s)>' % self.title



#同事表
class Colleague(db.Model):
    __tablename__='colleague'
    __table_args__={'useexisting':True}
    id=db.Column(db.Integer,primary_key=True)
    user_id=db.Column(db.Integer)
    colleague_id=db.Column(db.Integer)
    permission=db.Column(db.Integer)
    remark = db.Column(db.String(255))

#小组表
class Group(db.Model):
    __tablename__='group_list'
    __table_args__={'useexisting':True}
    id=db.Column(db.Integer,primary_key=True)
    group_name=db.Column(db.String(255))
    group_mark=db.Column(db.String(255))
    group_key =db.Column(db.String(255))
    group_task = db.Column(db.String(255))
    group_leader = db.Column(db.Integer)
    group_leader_name = db.String;

#小组成员表
class GroupMember(db.Model):
    __tablename__ = 'group_member'
    __table_args__ = {'useexisting': True}
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer)
    group_id = db.Column(db.Integer)
